package com.smart.utils;

import com.smart.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class SMUtils {

    public static String getWorkNum(int count){
        StringBuilder workNum = new StringBuilder("SH");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        workNum.append(sdf.format(new Date()));
        for (int i = 0; i < 5 - String.valueOf(count + 1).length(); i++){
            workNum.append("0");
        }
        return workNum.append(count + 1).toString();
    }

    public static String getDeptCode(Long id){
        StringBuilder deptCode = new StringBuilder("DEPT");
        for (int i = 0; i < 5 - String.valueOf(id).length(); i++){
            deptCode.append("0");
        }
        return deptCode.append(id).toString();
    }

    public static String listToString(List idList) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < idList.size(); i++) {
            builder.append(idList.get(i))
                    .append(i == (idList.size() - 1) ? "" : ",");
        }
        System.out.println("字符串：" + builder.toString());
        return builder.toString();
    }

}
